<template>
    <div class="detail-box">
        <div class="btns">
            <div class="back" @click="$router.go(-1)">
                <i class="iconfont icon-left"></i>
            </div>
            <router-link class="cart" to="/cart" tag="div">
                <i class="iconfont icon-cart"></i>
            </router-link>
        </div>
        <ScrollView class="product">
            <div>
                <SwiperView class="imgs" :options="swiperOption">
                    <img
                        v-for="(item, index) in 4"
                        :key="index"
                        class="swiper-slide"
                        :src="product.img"
                    />
                </SwiperView>
                <div class="info">
                    <div class="price">
                        <span class="code">￥</span>
                        <span class="new">{{ product.price }}</span>
                        <span class="old">￥{{ product.orgPrice }}</span>
                    </div>
                    <p class="desc">{{ product.title }}</p>
                    <span class="postage">免运费</span>
                </div>
                <div class="message">
                    <div>
                        <div class="caption">优惠</div>
                        <div class="substance">
                            <span>领券后，下单至少可减</span>
                            <span class="hint">3元</span>
                            <span class="more">
                                领劵
                                <i class="iconfont icon-right"></i>
                            </span>
                            <ul class="coupon">
                                <li class="title">店铺优惠卷</li>
                                <li class="item">满98减3</li>
                                <li class="item">满198减10</li>
                            </ul>
                        </div>
                    </div>
                    <div>
                        <div class="caption">促销</div>
                        <div class="substance">
                            <span class="kind">满折</span>
                            <span>满3件打9.5折，满99件打8.5折</span>
                            <span class="more">
                                更多
                                <i class="iconfont icon-right"></i>
                            </span>
                        </div>
                        <ul class="promise">
                            <li>
                                <i class="iconfont icon-success"></i>72小时发货
                            </li>
                            <li>
                                <i class="iconfont icon-success"></i>7天无理由退货
                            </li>
                            <li>
                                <i class="iconfont icon-success"></i>退货补运费
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="comments">
                    <div class="tips">
                        <div>
                            <span>买家评价</span>
                            <span>222</span>
                            <span class="more">
                                更多
                                <i class="iconfont icon-right"></i>
                            </span>
                        </div>
                        <ul>
                            <li v-for="(item, index) in 10" :key="index">评论完成({{ 4 }})</li>
                        </ul>
                    </div>
                    <div class="comm" v-for="(comm,index) in 10" :key="index">
                        <div class="user">
                            <div class="user-img">
                                <img src="../../public/img/about/collect.png" />
                            </div>
                            <div class="user-name">测试名称</div>
                            <div class="create-time">2020年02月10日22:45:59</div>
                        </div>
                        <div class="msg">
                            <div class="user-msg">测试名称测试名称测试名称测试名称测试名称测试名称测试名称测试名称</div>
                            <div class="line" v-show="false"></div>
                            <div class="back-msg" v-show="true">测试名称测试名称测试名称测试名称</div>
                        </div>
                        <div class="photos">
                            <div class="img" v-for="(item, index) in 3" :key="index">
                                <img src="../../public/img/actor.jpg" alt srcset />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ScrollView>
        <div class="setting">
            <div class="icon">
                <i class="iconfont icon-shop"></i>
                <span>店铺</span>
            </div>
            <div class="icon">
                <i class="iconfont icon-message"></i>
                <span>客服</span>
            </div>
            <div class="icon">
                <i class="iconfont icon-like"></i>
                <span>收藏</span>
            </div>
            <div class="btn cart"  @click="addCart()" >加入购物车</div>
            <div class="btn buy">立即购买</div>
        </div>
        <FiexdMenus></FiexdMenus>
    </div>
</template>
<script>
import { mapMutations } from 'vuex';
export default {
    name:"detail",
    data() {
        return {
            swiperOption: {
                effect: "coverflow", // 切换卡的效果
                slidesPerView: 3,
                centeredSlides: true
            },
            product: {}
        };
    },
    methods: {
        ...mapMutations( ["addCartItem"] ),
        addCart(){
            this.product.flag = false;
            this.addCartItem(this.product);
            this.$showTip("添加完成")
        },
        loadProductDetail() {
            // 正常项目开发，完成 根据 产品ID 发送ajax请求

            // 模拟方式
            let str = localStorage.getItem(this.$route.query.iid);
            this.product = JSON.parse(str);
        }
    },
    mounted() {
        this.loadProductDetail();
    }
};
</script>
<style lang="less" scoped>
.detail-box {
    height: 100%;
    position: relative;
    background-color: @ef;
    .btns {
        height: 100px;
        font-size: 0px;
        color: white;
        position: absolute;
        width: 100%;
        z-index: 2;
        > div {
            background-color: rgba(0, 0, 0, 0.6);
            margin: 20px;
            width: 60px;
            height: 60px;
            text-align: center;
            border-radius: 50%;
            i {
                font-size: 32px;
                font-weight: bolder;
                line-height: 60px;
                color: white;
            }
        }
        .back {
            float: left;
        }
        .cart {
            float: right;
        }
    }
    .product {
        position: absolute;
        top: 0px;
        bottom: @h;
        width: 100%;
        .imgs {
            width: 200%;
            // width: 100%;
            // position: relative;
            // left: -50%;
            transform: translateX(-25%);
            text-align: center;
            white-space: nowrap;
            font-size: 0px;
            box-sizing: border-box;
            img {
                width: 100%;
                object-fit: cover;
                object-position: center;
                padding: 10px;
                box-sizing: border-box;
            }
        }
        .info {
            background-color: white;
            margin-bottom: 20px;
            font-size: 0px;
            padding: 20px;
            .price {
                font-size: 26px;
                color: @gray;
                font-weight: 350;
                .code {
                    vertical-align: top;
                }
                .new {
                    font-size: 54px;
                    line-height: 54px;
                }
                .old {
                    padding-left: 20px;
                    color: @99;
                    text-decoration: line-through;
                }
            }
            .desc {
                padding-top: 10px;
                font-size: 34px;
                font-weight: 340;
                text-indent: 20px;
            }
            .postage {
                padding-top: 10px;
                font-size: 24px;
                display: inline-block;
                color: @99;
            }
        }
        .message {
            background-color: white;
            padding: 20px;
            line-height: 50px;
            .caption {
                color: @99;
                font-size: 28px;
                font-weight: bold;
                margin-right: 40px;
                float: left;
            }
            .substance {
                font-size: 28px;
            }
            .hint {
                color: @pink;
            }
            .more {
                float: right;
                color: @99;
            }
            .kind {
                color: @pink;
                background-color: @pink1;
                padding: 0px 16px;
                margin-right: 20px;
                border-radius: 100px;
            }
            .coupon {
                list-style: none;
                color: @pink;
                margin: 10px 0px;
                li {
                    display: inline-block;
                    padding: 0px 16px;
                    margin-right: 20px;
                }
                .title {
                    background-color: @pink1;
                    border-radius: 100px;
                }
                .item {
                    // border: 1PX solid @pink;
                    // line-height: 44px;
                    background-color: @pink1;
                    position: relative;
                    &::before {
                        content: "";
                        display: inline-block;
                        width: 20px;
                        height: 20px;
                        // border: 1PX solid @pink;
                        border-radius: 50%;
                        position: absolute;
                        left: -8px;
                        top: 15px;
                        background-color: white;
                        transform: translateZ(10px);
                        z-index: 10;
                    }
                    &::after {
                        content: "";
                        display: inline-block;
                        width: 20px;
                        height: 20px;
                        // border: 1PX solid @pink;
                        border-radius: 50%;
                        position: absolute;
                        right: -8px;
                        top: 15px;
                        background-color: white;
                        transform: translateZ(10px);
                        z-index: 10;
                    }
                }
            }
            .promise {
                list-style: none;
                font-size: 28px;
                text-align: center;
                padding: 0px;
                padding-top: 30px;
                border-top: 1px solid @de;
                li {
                    line-height: 40px;
                    display: inline-block;
                    margin-right: 40px;
                    i {
                        color: @pink;
                        font-size: 36px;
                        vertical-align: middle;
                    }
                }
            }
        }
        .comments {
            margin-top: 30px;
            background-color: white;
            font-size: 28px;
            color: @99;
            padding: 20px;
            .more {
                float: right;
                color: @99;
            }
            .tips {
                ul {
                    list-style: none;
                    padding: 20px 0px;
                    font-size: 28px;
                    line-height: 50px;
                    li {
                        display: inline-block;
                        background-color: @pink1;
                        color: @pink;
                        margin-right: 20px;
                        padding: 0px 10px;
                        margin-bottom: 10px;
                    }
                }
            }
            .comm {
                margin: 20px 0px;
                font-size: 28px;
                .user {
                    margin-bottom: 20px;
                    .user-img {
                        width: 100px;
                        height: 100px;
                        border-radius: 50%;
                        float: left;
                        img {
                            width: 100%;
                            height: 100%;
                            object-fit: cover;
                            object-position: center;
                        }
                    }
                    .user-name {
                        margin-left: 120px;
                        height: 70px;
                        line-height: 70px;
                        color: @gray;
                        font-size: 32px;
                    }
                    .create-time {
                        margin-left: 120px;
                        height: 30px;
                        line-height: 30px;
                        font-size: 24px;
                    }
                }
                .msg {
                    text-indent: 40px;
                    color: @gray;
                    line-height: 48px;
                    margin-bottom: 20px;
                    .line {
                        border: 1px dotted @99;
                        margin: 20px;
                    }
                    .back-msg > span {
                        color: @pink;
                    }
                }
                .photos {
                    display: flex;
                    flex-flow: row wrap;
                    .img {
                        width: 100% / 4;
                        padding-bottom: 100% / 4;
                        position: relative;
                        margin-bottom: 20px;
                        img {
                            position: absolute;
                            top: 0px;
                            width: 100%;
                            height: 100%;
                            object-fit: cover;
                            object-position: top center;
                            padding-right: 20px;
                            box-sizing: border-box;
                        }
                    }
                }
            }
        }
    }
    .setting {
        position: absolute;
        bottom: 0px;
        width: 100%;
        height: @h;
        background-color: white;
        font-size: 0px;
        display: flex;
        flex-flow: row nowrap;
        z-index: 10;
        .icon {
            font-size: 24px;
            color: @66;
            height: 100%;
            width: @h;
            border: 1px solid @de;
            box-sizing: border-box;
            border-left: none;
            text-align: center;
            padding: 10px;
            &:first-child {
                border-left: 1px solid @cc;
            }
            i {
                font-size: 36px;
            }
            span {
                display: block;
            }
        }
        .btn {
            flex-grow: 1;
            font-size: 28px;
            text-align: center;
            line-height: @h;
            color: white;
            font-weight: 400;
            // border-top: 1PX solid @cc;
            box-sizing: border-box;
            cursor: pointer;
        }
        .cart {
            background-color: @pink1;
            color: @pink;
            &:active {
                background-color: @pink2;
            }
        }
        .buy {
            background-color: @pink;
            &:active {
                background-color: @light-pink;
            }
        }
    }
}
</style>
